/**
 * 
 */
package hu.gbalage.owlforms.impl;

import hu.gbalage.owlforms.api.FieldCardinality;
import hu.gbalage.owlforms.api.data.FieldData;

/**
 * @author Grill Balazs (balage.g@gmail.com)
 *
 */
public class AndFieldCardinality implements FieldCardinality {

	private final FieldCardinality c1;
	private final FieldCardinality c2;
	
	public AndFieldCardinality(FieldCardinality c1, FieldCardinality c2){
		this.c1 = c1;
		this.c2 = c2;
	}
	
	/* (non-Javadoc)
	 * @see hu.gbalage.owlforms.api.FieldCardinality#canAddMore(hu.gbalage.owlforms.api.data.FieldData)
	 */
	public boolean canAddMore(FieldData fielddata) {
		return c1.canAddMore(fielddata)&&c2.canAddMore(fielddata);
	}

	/* (non-Javadoc)
	 * @see hu.gbalage.owlforms.api.FieldCardinality#isSufficient(hu.gbalage.owlforms.api.data.FieldData)
	 */
	public boolean isSufficient(FieldData fielddata) {
		return c1.isSufficient(fielddata)&&c2.isSufficient(fielddata);
	}

	public int getMax() {
		return Math.min(c1.getMax(), c2.getMax());
	}
	
	public int getMin() {
		return Math.max(c1.getMin(), c2.getMin());
	}
	
}
